<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>linux常用命令合集(1) | Gjboy</title><meta name="keywords" content="linux Command"><meta name="author" content="ZyhCs"><meta name="copyright" content="ZyhCs"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="本篇小度°总结了在学习linux过程使用到的一些命令，这些命令大部分在linux中都能使用的到，有需要的可以学习下。"><meta property="og:type" content="article"><meta property="og:title" content="linux常用命令合集(1)"><meta property="og:url" content="http://zyhcs.gitee.io/blog/posts/6d26b718.html"><meta property="og:site_name" content="Gjboy"><meta property="og:description" content="本篇小度°总结了在学习linux过程使用到的一些命令，这些命令大部分在linux中都能使用的到，有需要的可以学习下。"><meta property="og:locale" content="zh_CN"><meta property="og:image" content="https://gitee.com/zyhcs/image/raw/master/20201014202220.png"><meta property="article:published_time" content="2021-02-11T06:10:01.000Z"><meta property="article:modified_time" content="2021-03-28T04:00:44.161Z"><meta property="article:author" content="ZyhCs"><meta property="article:tag" content="Linux"><meta property="article:tag" content="Command"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://gitee.com/zyhcs/image/raw/master/20201014202220.png"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="http://zyhcs.gitee.io/blog/posts/6d26b718"><link rel="preconnect" href="//cdn.jsdelivr.net"><link rel="preconnect" href="//hm.baidu.com"><link rel="preconnect" href="//s4.cnzz.com"><link rel="preconnect" href="//busuanzi.ibruce.info"><link rel="manifest" href="/blog/img/pwa/manifest.json"><link rel="apple-touch-icon" sizes="180x180" href="/blog/img/pwa/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/blog/img/pwa/32.png"><link rel="icon" type="image/png" sizes="16x16" href="/blog/img/pwa/16.png"><link rel="mask-icon" href="/blog/img/pwa/safari-pinned-tab.svg" color="#5bbad5"><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload='this.media="all"'><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?2dc053e49a4d0ec097db7a88694f605a";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script async data-pjax="data-pjax" src="https://s4.cnzz.com/z_stat.php?id=1279722549&amp;web_id=1279722549"></script><script>const GLOBAL_CONFIG={root:"/blog/",algolia:void 0,localSearch:{path:"search.xml",languages:{hits_empty:"找不到您查询的内容：${query}"}},translate:{defaultEncoding:2,translateDelay:0,msgToTraditionalChinese:"繁",msgToSimplifiedChinese:"簡"},noticeOutdate:void 0,highlight:{plugin:"highlighjs",highlightCopy:!0,highlightLang:!0},copy:{success:"复制成功",error:"复制错误",noSupport:"浏览器不支持"},relativeDate:{homepage:!1,post:!0},runtime:"天",date_suffix:{just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},copyright:void 0,lightbox:"mediumZoom",Snackbar:{chs_to_cht:"你已切换为繁体",cht_to_chs:"你已切换为简体",day_to_night:"你已切换为深色模式",night_to_day:"你已切换为浅色模式",bgLight:"#49b1f5",bgDark:"#121212",position:"bottom-left"},source:{jQuery:"https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js",justifiedGallery:{js:"https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js",css:"https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css"},fancybox:{js:"https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js",css:"https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"}},isPhotoFigcaption:!0,islazyload:!0,isanchor:!1}</script><script id="config-diff">var GLOBAL_CONFIG_SITE={isPost:!0,isHome:!1,isHighlightShrink:!1,isToc:!0,postUpdate:"2021-03-28 12:00:44"}</script><noscript><style>#nav{opacity:1}.justified-gallery img{opacity:1}#post-meta time,#recent-posts time{display:inline!important}</style></noscript><script>(e=>{e.saveToLocal={set:function(e,t,o){if(0===o)return;const a=864e5*o,n={value:t,expiry:(new Date).getTime()+a};localStorage.setItem(e,JSON.stringify(n))},get:function(e){const t=localStorage.getItem(e);if(!t)return;const o=JSON.parse(t);if(!((new Date).getTime()>o.expiry))return o.value;localStorage.removeItem(e)}},e.getScript=e=>new Promise((t,o)=>{const a=document.createElement("script");a.src=e,a.async=!0,a.onerror=o,a.onload=a.onreadystatechange=function(){const e=this.readyState;e&&"loaded"!==e&&"complete"!==e||(a.onload=a.onreadystatechange=null,t())},document.head.appendChild(a)}),e.activateDarkMode=function(){document.documentElement.setAttribute("data-theme","dark"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#0d0d0d")},e.activateLightMode=function(){document.documentElement.setAttribute("data-theme","light"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#ffffff")};const t=saveToLocal.get("theme"),o=(new Date).getHours();void 0===t?o<=6||o>=18?activateDarkMode():activateLightMode():"light"===t?activateLightMode():activateDarkMode();const a=saveToLocal.get("aside-status");void 0!==a&&("hide"===a?document.documentElement.classList.add("hide-aside"):document.documentElement.classList.remove("hide-aside"))})(window)</script><meta name=" -site-verification" content="brIBW7JhHugYUFjAnO-t1-UZWYnopQuMfM8LbBKcUPo"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css" media="defer" onload='this.media="all"'><link rel="preconnect" href="https://fonts.gstatic.com"><link href="https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap" rel="stylesheet"><style>.app-refresh{position:fixed;top:-2.2rem;left:0;right:0;z-index:99999;padding:0 1rem;font-size:15px;height:2.2rem;transition:all .3s ease}.app-refresh-wrap{display:flex;color:#fff;height:100%;align-items:center;justify-content:center}.app-refresh-wrap a{color:#fff;text-decoration:underline;cursor:pointer}</style><meta name="generator" content="Hexo 5.4.0"><style>.github-emoji{position:relative;display:inline-block;width:1.2em;min-height:1.2em;overflow:hidden;vertical-align:top;color:transparent}.github-emoji>span{position:relative;z-index:10}.github-emoji .fancybox,.github-emoji img{margin:0!important;padding:0!important;border:none!important;outline:0!important;text-decoration:none!important;user-select:none!important;cursor:auto!important}.github-emoji img{height:1.2em!important;width:1.2em!important;position:absolute!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;user-select:none!important;cursor:auto!important}.github-emoji-fallback{color:inherit}.github-emoji-fallback img{opacity:0!important}</style><link rel="alternate" href="/blog/atom.xml" title="Gjboy" type="application/atom+xml"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/avatar.jpg" onerror='onerror=null,src="/img/friend_404.gif"' alt="avatar"></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">9</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div></div><hr><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i> <span>首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i> <span>归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i> <span>标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tools/"><i class="fa-fw fas fa-tools"></i> <span>工具</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i> <span>追系列</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/blog/book/"><i class="fa-fw fas fa-book"></i> <span>阅读</span></a></li><li><a class="site-page" href="/blog/bangumis/"><i class="fa-fw fas fa-tools"></i> <span>番剧</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/blog/blogroll/"><i class="fa-fw fas fa-tools"></i> <span>Blog订阅</span></a></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fas fa-link"></i> <span>友链</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-heart"></i> <span>其他</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i> <span>关于我</span></a></li><li><a class="site-page" href="/blog/guestbook/"><i class="fa-fw fas fa-book"></i> <span>留言板</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image:url(https://gitee.com/zyhcs/image/raw/master/20201014202220.png)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">Gjboy</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i> <span>搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i> <span>首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i> <span>归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i> <span>标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tools/"><i class="fa-fw fas fa-tools"></i> <span>工具</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i> <span>追系列</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/blog/book/"><i class="fa-fw fas fa-book"></i> <span>阅读</span></a></li><li><a class="site-page" href="/blog/bangumis/"><i class="fa-fw fas fa-tools"></i> <span>番剧</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/blog/blogroll/"><i class="fa-fw fas fa-tools"></i> <span>Blog订阅</span></a></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fas fa-link"></i> <span>友链</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-heart"></i> <span>其他</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i> <span>关于我</span></a></li><li><a class="site-page" href="/blog/guestbook/"><i class="fa-fw fas fa-book"></i> <span>留言板</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">linux常用命令合集(1)</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-02-11T06:10:01.000Z" title="发表于 2021-02-11 14:10:01">2021-02-11</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-03-28T04:00:44.161Z" title="更新于 2021-03-28 12:00:44">2021-03-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/Linux/">Linux</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">4.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>15分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="Linux常用命令合集-1"><a href="#Linux常用命令合集-1" class="headerlink" title="Linux常用命令合集(1)"></a>Linux常用命令合集(1)</h2><h4 id="1-处理目录的常用命令："><a href="#1-处理目录的常用命令：" class="headerlink" title="1.处理目录的常用命令："></a><strong>1.处理目录的常用命令：</strong></h4><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">ls（英文全拼：list files）: 列出目录及文件名</span><br><span class="line"><span class="built_in">cd</span>（英文全拼：change directory）：切换目录</span><br><span class="line"><span class="built_in">pwd</span>（英文全拼：<span class="built_in">print</span> work directory）：显示目前的目录</span><br><span class="line">mkdir（英文全拼：make directory）：创建一个新的目录</span><br><span class="line">rmdir（英文全拼：remove directory）：删除一个空的目录</span><br><span class="line">cp（英文全拼：copy file）: 复制文件或目录</span><br><span class="line">rm（英文全拼：remove）: 移除文件或目录</span><br><span class="line">mv（英文全拼：move file）: 移动文件与目录，或修改文件与目录的名称</span><br><span class="line">你可以使用 man [命令] 来查看各个命令的使用文档，如 ：man cp。</span><br></pre></td></tr></tbody></table></figure><ul><li><strong>ls(列出目录):</strong>在Linux系统当中， ls 命令可能是最常被运行的。</li></ul><p><strong>- 语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ls [-aAdfFhilnrRSt] 目录名称</span><br><span class="line">ls [--color={never,auto,always}] 目录名称</span><br><span class="line">ls [--full-time] 目录名称</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-a ：全部的文件，连同隐藏文件( 开头为 . 的文件) 一起列出来(常用)</li><li>-d ：仅列出目录本身，而不是列出目录内的文件数据(常用)</li><li>-l ：长数据串列出，包含文件的属性与权限等等数据；(常用)</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 将家目录下的所有文件列出来(含属性与隐藏档)</span><br><span class="line">[root@www ~]<span class="comment"># ls -al ~</span></span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>cd(切换目录):</strong>cd是Change Directory的缩写，这是用来变换工作目录的命令。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> [相对路径或绝对路径]</span><br></pre></td></tr></tbody></table></figure><br><strong>-举例:</strong><p></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 使用 mkdir 命令创建 runoob 目录</span><br><span class="line">[root@www ~]<span class="comment"># mkdir runoob</span></span><br><span class="line">&gt; - 使用绝对路径切换到 runoob 目录</span><br><span class="line">[root@www ~]<span class="comment"># cd /root/runoob/</span></span><br><span class="line">&gt; - 使用相对路径切换到 runoob 目录</span><br><span class="line">[root@www ~]<span class="comment"># cd ./runoob/</span></span><br><span class="line">&gt; - 表示回到自己的家目录，亦即是 /root 这个目录</span><br><span class="line">[root@www runoob]<span class="comment"># cd ~</span></span><br><span class="line">&gt; - 表示去到目前的上一级目录，亦即是 /root 的上一级目录的意思；</span><br><span class="line">[root@www ~]<span class="comment"># cd ..</span></span><br></pre></td></tr></tbody></table></figure><ul><li><strong>pwd(显示目前所在的目录):</strong>pwd 是 Print Working Directory 的缩写，也就是显示目前所在目录。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">pwd</span> [-p]</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-p ：显示出确实的路径，而非使用连结 (link) 路径。</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 单纯显示出目前的工作目录：</span><br><span class="line">[root@www ~]<span class="comment"># pwd</span></span><br><span class="line">/root   &lt;== 显示出目录啦～</span><br><span class="line">实例显示出实际的工作目录，而非连结档本身的目录名而已。</span><br><span class="line">[root@www ~]<span class="comment"># cd /var/mail   &lt;==注意，/var/mail是一个连结档</span></span><br><span class="line">[root@www mail]<span class="comment"># pwd</span></span><br><span class="line">/var/mail         &lt;==列出目前的工作目录</span><br><span class="line">[root@www mail]<span class="comment"># pwd -P</span></span><br><span class="line">/var/spool/mail   &lt;==怎么回事？有没有加 -P 差很多～</span><br><span class="line">[root@www mail]<span class="comment"># ls -ld /var/mail</span></span><br><span class="line">lrwxrwxrwx 1 root root 10 Sep  4 17:54 /var/mail -&gt; spool/mail</span><br><span class="line">因为 /var/mail 是连结档，连结到 /var/spool/mail 所以，加上 <span class="built_in">pwd</span> -P 的选项后，会不以连结档的数据显示，而是显示正确的完整路径</span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>mkdir(创建新目录):</strong>创建新的目录，使用mkdir(make directory)</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&gt;mkdir [-mp] 目录名称</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-m ：配置文件的权限!直接配置，不需要看默认权限(umask)的脸色。</li><li>-p ：帮助你直接将所需要的目录(包含上一级目录)递归创建起来。</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 请到/tmp底下尝试创建数个新目录看看：</span><br><span class="line">[root@www ~]<span class="comment"># cd /tmp</span></span><br><span class="line">[root@www tmp]<span class="comment"># mkdir test    &lt;==创建一名为 test 的新目录</span></span><br><span class="line">[root@www tmp]<span class="comment"># mkdir test1/test2/test3/test4</span></span><br><span class="line">mkdir: cannot create directory `test1/test2/test3/test4<span class="string">': </span></span><br><span class="line"><span class="string">No such file or directory       &lt;== 没办法直接创建此目录！</span></span><br><span class="line"><span class="string">[root@www tmp]# mkdir -p test1/test2/test3/test4</span></span><br><span class="line"><span class="string">加了这个 -p 的选项，可以自行帮你创建多层目录！</span></span><br><span class="line"><span class="string">&gt; - 创建权限为 rwx--x--x 的目录。</span></span><br><span class="line"><span class="string">[root@www tmp]# mkdir -m 711 test2</span></span><br><span class="line"><span class="string">[root@www tmp]# ls -l</span></span><br><span class="line"><span class="string">drwxr-xr-x  3 root  root 4096 Jul 18 12:50 test</span></span><br><span class="line"><span class="string">drwxr-xr-x  3 root  root 4096 Jul 18 12:53 test1</span></span><br><span class="line"><span class="string">drwx--x--x  2 root  root 4096 Jul 18 12:54 test2</span></span><br></pre></td></tr></tbody></table></figure><br><strong>注意</strong>：上面的权限部分，如果没有加上 -m 来强制配置属性，系统会使用默认属性。<br>如果我们使用 -m ，如上例我们给予 -m 711 来给予新的目录 drwx—x—x 的权限。<p></p><ul><li><strong>rmdir(删除目录):</strong>删除空的目录</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rmdir [-p] 目录名称</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-p ：连同上一级『空的』目录也一起删除</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 删除 runoob 目录</span><br><span class="line">[root@www tmp]<span class="comment"># rmdir runoob/</span></span><br><span class="line">&gt; - 将 mkdir 实例中创建的目录(/tmp 底下)删除掉！</span><br><span class="line">[root@www tmp]<span class="comment"># ls -l   &lt;==看看有多少目录存在？</span></span><br><span class="line">drwxr-xr-x  3 root  root 4096 Jul 18 12:50 <span class="built_in">test</span></span><br><span class="line">drwxr-xr-x  3 root  root 4096 Jul 18 12:53 test1</span><br><span class="line">drwx--x--x  2 root  root 4096 Jul 18 12:54 test2</span><br><span class="line">[root@www tmp]<span class="comment"># rmdir test   &lt;==可直接删除掉，没问题</span></span><br><span class="line">[root@www tmp]<span class="comment"># rmdir test1  &lt;==因为尚有内容，所以无法删除！</span></span><br><span class="line">rmdir: `test1<span class="string">': Directory not empty</span></span><br><span class="line"><span class="string">[root@www tmp]# rmdir -p test1/test2/test3/test4</span></span><br><span class="line"><span class="string">[root@www tmp]# ls -l        &lt;==底下的输出中test与test1不见了！</span></span><br><span class="line"><span class="string">drwx--x--x  2 root  root 4096 Jul 18 12:54 test2</span></span><br><span class="line"><span class="string">利用 -p 这个选项，立刻就可以将 test1/test2/test3/test4 一次删除。</span></span><br></pre></td></tr></tbody></table></figure><br><strong>-注意:</strong>这个 rmdir 仅能删除空的目录，你可以使用 rm 命令来删除非空目录。<p></p><ul><li><strong>cp(复制文件或目录):</strong>cp 即拷贝文件和目录。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cp [-adfilprsu] 来源档(<span class="built_in">source</span>) 目标档(destination)</span><br><span class="line">cp [options] source1 source2 source3 .... directory</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-a：相当于 -pdr 的意思，至於 pdr 请参考下列说明；(常用)</li><li>-d：若来源档为连结档的属性(link file)，则复制连结档属性而非文件本身；</li><li>-f：为强制(force)的意思，若目标文件已经存在且无法开启，则移除后再尝试一次；</li><li>-i：若目标档(destination)已经存在时，在覆盖时会先询问动作的进行(常用)</li><li>-l：进行硬式连结(hard link)的连结档创建，而非复制文件本身；</li><li>-p：连同文件的属性一起复制过去，而非使用默认属性(备份常用)；</li><li>-r：递归持续复制，用於目录的复制行为；(常用)</li><li>-s：复制成为符号连结档 (symbolic link)，亦即『捷径』文件；</li><li>-u：若 destination 比 source 旧才升级 destination ！</li></ul><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 用 root 身份，将 root 目录下的 .bashrc 复制到 /tmp 下，并命名为 bashrc</span><br><span class="line">[root@www ~]<span class="comment"># cp ~/.bashrc /tmp/bashrc</span></span><br><span class="line">[root@www ~]<span class="comment"># cp -i ~/.bashrc /tmp/bashrc</span></span><br><span class="line">cp: overwrite `/tmp/bashrc<span class="string">'? n  &lt;==n不覆盖，y为覆盖</span></span><br></pre></td></tr></tbody></table></figure><p></p></blockquote><ul><li><strong>rm(移除文件或目录):</strong>删除指定的文件或目录(含有内容)</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm [-fir] 文件或目录</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-f ：就是 force 的意思，忽略不存在的文件，不会出现警告信息；</li><li>-i ：互动模式，在删除前会询问使用者是否动作</li><li>-r ：<strong>递归删除！最常用在目录的删除了！这是非常危险的选项！！！</strong></li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 将刚刚在 cp 的实例中创建的 bashrc 删除掉！</span><br><span class="line">[root@www tmp]<span class="comment"># rm -i bashrc</span></span><br><span class="line">rm: remove regular file `bashrc<span class="string">'? y</span></span><br><span class="line"><span class="string">如果加上 -i 的选项就会主动询问，避免你删除到错误的档名！</span></span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>mv(移动文件与目录，或修改名称):</strong> 对指定的文件或目录进行移动</li></ul><p><strong>-语法</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mv [-fiu] <span class="built_in">source</span> destination</span><br><span class="line">mv [options] source1 source2 source3 .... directory</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-f ：force 强制的意思，如果目标文件已经存在，不会询问而直接覆盖；</li><li>-i ：若目标文件 (destination) 已经存在时，就会询问是否覆盖！</li><li>-u ：若目标文件已经存在，且 source 比较新，才会升级 (update)</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 复制一文件，创建一目录，将文件移动到目录中</span><br><span class="line">[root@www ~]<span class="comment"># cd /tmp</span></span><br><span class="line">[root@www tmp]<span class="comment"># cp ~/.bashrc bashrc</span></span><br><span class="line">[root@www tmp]<span class="comment"># mkdir mvtest</span></span><br><span class="line">[root@www tmp]<span class="comment"># mv bashrc mvtest</span></span><br><span class="line">将某个文件移动到某个目录去，就是这样做！</span><br><span class="line">&gt; - 将刚刚的目录名称更名为 mvtest2</span><br><span class="line">[root@www tmp]<span class="comment"># mv mvtest mvtest2</span></span><br></pre></td></tr></tbody></table></figure><p></p><h4 id="2-内容查看的常用命令"><a href="#2-内容查看的常用命令" class="headerlink" title="2.内容查看的常用命令:"></a><strong>2.内容查看的常用命令:</strong></h4><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">cat  由第一行开始显示文件内容</span><br><span class="line">tac  从最后一行开始显示，可以看出 tac 是 cat 的倒着写！</span><br><span class="line">nl   显示的时候，顺道输出行号！</span><br><span class="line">more 一页一页的显示文件内容</span><br><span class="line">less 与 more 类似，但是比 more 更好的是，他可以往前翻页！</span><br><span class="line">head 只看头几行</span><br><span class="line">tail 只看尾巴几行</span><br><span class="line">你可以使用 man [命令]来查看各个命令的使用文档，如 ：man cp。</span><br></pre></td></tr></tbody></table></figure><ul><li><strong>cat:</strong>由第一行开始显示文件内容</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat [-AbEnTv]</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-A ：相当于 -vET 的整合选项，可列出一些特殊字符而不是空白而已；</li><li>-b ：列出行号，仅针对非空白行做行号显示，空白行不标行号！</li><li>-E ：将结尾的断行字节 $ 显示出来；</li><li>-n ：列印出行号，连同空白行也会有行号，与 -b 的选项不同；</li><li>-T ：将 [tab] 按键以 ^I 显示出来；</li><li>-v ：列出一些看不出来的特殊字符</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 检看 /etc/issue 这个文件的内容：</span><br><span class="line">[root@www ~]<span class="comment"># cat /etc/issue</span></span><br><span class="line">CentOS release 6.4 (Final)</span><br><span class="line">Kernel \r on an \m</span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>tac:</strong>与cat命令相反，文件内容从最后一行开始显示，可以看出 tac 是 cat 的倒着写。</li></ul><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@www ~]<span class="comment"># tac /etc/issue</span></span><br><span class="line">Kernel \r on an \m</span><br><span class="line">CentOS release 6.4 (Final)</span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>nl:</strong>显示行号。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nl [-bnw] 文件</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-b ：指定行号指定的方式，主要有两种：</li><li>-b a ：表示不论是否为空行，也同样列出行号(类似 cat -n)；</li><li>-b t ：如果有空行，空的那一行不要列出行号(默认值)；</li><li>-n ：列出行号表示的方法，主要有三种：</li><li>-n ln ：行号在荧幕的最左方显示；</li><li>-n rn ：行号在自己栏位的最右方显示，且不加 0 ；</li><li>-n rz ：行号在自己栏位的最右方显示，且加 0 ；</li><li>-w ：行号栏位的占用的位数。</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">用 nl 列出 /etc/issue 的内容</span><br><span class="line">[root@www ~]<span class="comment"># nl /etc/issue</span></span><br><span class="line">     1  CentOS release 6.4 (Final)</span><br><span class="line">     2  Kernel \r on an \m</span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>more:</strong>一页一页翻动。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">more 文件名</span><br></pre></td></tr></tbody></table></figure><br><strong>-举例:</strong><p></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">[root@www ~]<span class="comment"># more /etc/man_db.config </span></span><br><span class="line">Generated automatically from man.conf.in by the</span><br><span class="line">configure script.</span><br><span class="line">man.conf from man-1.6d</span><br><span class="line">....(中间省略)....</span><br><span class="line">--More--(28%)  &lt;== 重点在这一行！你的光标也会在这里等待你的命令</span><br></pre></td></tr></tbody></table></figure><p><strong>-注意：</strong>在 more 这个程序的运行过程中，你有几个按键可以按的：</p><blockquote><ul><li>空白键 (space)：代表向下翻一页；</li><li>Enter ：代表向下翻『一行』；</li><li>/字串 ：代表在这个显示的内容当中，向下搜寻『字串』这个关键字；</li><li>:f ：立刻显示出档名以及目前显示的行数；</li><li>q ：代表立刻离开 more ，不再显示该文件内容。</li><li>b 或 [ctrl]-b ：代表往回翻页，不过这动作只对文件有用，对管线无用。</li></ul></blockquote><ul><li><strong>less:</strong>一页一页翻动。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">less 文件名</span><br></pre></td></tr></tbody></table></figure><br><strong>-举例：</strong><br><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 输出/etc/man.config文件的内容：</span><br><span class="line">[root@www ~]<span class="comment"># less /etc/man.config</span></span><br><span class="line">Generated automatically from man.conf.in by the</span><br><span class="line">configure script.</span><br><span class="line">man.conf from man-1.6d</span><br><span class="line">....(中间省略)....</span><br><span class="line">:   &lt;== 这里可以等待你输入命令！</span><br></pre></td></tr></tbody></table></figure><br><strong>-注意:</strong>less运行时可以输入的命令有：<p></p><blockquote><ul><li>空白键 ：向下翻动一页；</li><li>[pagedown]：向下翻动一页；</li><li>[pageup] ：向上翻动一页；</li><li>/字串 ：向下搜寻『字串』的功能；</li><li>?字串 ：向上搜寻『字串』的功能；</li><li>n ：重复前一个搜寻 (与 / 或 ? 有关！)</li><li>N ：反向的重复前一个搜寻 (与 / 或 ? 有关！)</li><li>q ：离开 less 这个程序；</li></ul></blockquote><ul><li><strong>head:</strong>取出文件前面几行<br><strong>-语法：</strong><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">head [-n number] 文件</span><br></pre></td></tr></tbody></table></figure><strong>-选项与参数:</strong><blockquote><ul><li>-n ：后面接数字，代表显示几行的意思</li></ul></blockquote></li></ul><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@www ~]<span class="comment"># head /etc/man.config</span></span><br><span class="line">默认的情况中，显示前面 10 行！若要显示前 20 行，就得要这样：</span><br><span class="line">[root@www ~]<span class="comment"># head -n 20 /etc/man.config</span></span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>tail:</strong>取出文件后面几行<blockquote><p><strong>-语法:</strong></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tail [-n number] 文件</span><br></pre></td></tr></tbody></table></figure><p><strong>-选项与参数:</strong></p></blockquote></li></ul><blockquote><ul><li>-n ：后面接数字，代表显示几行的意思</li><li>-f ：表示持续侦测后面所接的档名，要等到按下[ctrl]-c才会结束tail的侦测</li></ul><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@www ~]<span class="comment"># tail /etc/man.config</span></span><br><span class="line">默认的情况中，显示最后的十行！若要显示最后的 20 行，就得要这样：</span><br><span class="line">[root@www ~]<span class="comment"># tail -n 20 /etc/man.config</span></span><br></pre></td></tr></tbody></table></figure><p></p></blockquote><h4 id="3-搜索查找类命令："><a href="#3-搜索查找类命令：" class="headerlink" title="3.搜索查找类命令："></a>3.搜索查找类命令：</h4><ul><li><strong>find:</strong>从指定目录向下递归的遍历其各个子目录，将满足条件的文件或者目录显示在终端。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find 目标源 [选项]</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-name:按照指定的文件名查找文件</li><li>-user:查找属于指定用户名的所有文件</li><li>-size:按照指定的文件大小查找文件</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 根据名称查找/home目录下的hello.txt文件</span><br><span class="line">find /home -name hello.txt</span><br><span class="line">&gt; - 查找/opt目录下属于root用户的文件</span><br><span class="line">find /opt -user root</span><br><span class="line">&gt; - 查找整个linux系统下大于20M的文件(+n大于、-n小于、n等于)</span><br><span class="line">find / -size +20M</span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>locate:</strong>可以快速定位文件路径，无需遍历整个文件系统，查询速度较快。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">locate 目标文件</span><br></pre></td></tr></tbody></table></figure><br><strong>-特别说明:</strong><p></p><blockquote><ul><li>locate指令利用事先建立的系统中所有文件名称及路径的locate数据库实现快速定位给定的文件。为了保证查询结果的准确度，管理员必须定期更新locate时刻。由于locate指令基于数据库进行查询，所以第一次运行前，必须使用updatedb指令创建locate数据库。</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 使用locate指令快速定位hello.txt文件所在目录</span><br><span class="line">&gt;  locate hello.txt </span><br></pre></td></tr></tbody></table></figure><p></p><ul><li><strong>grep:</strong>过滤查找(在文件内部查找);<strong>管道符号”|”:</strong>将前一个命令的处理结果传递给后面的命令处理。</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep [选项] 查找内容 源文件</span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-n:显示匹配行和行号</li><li>-i:忽略字母及大小</li></ul></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 在hello.txt中，查找<span class="string">"yes"</span>所在行，并显示行号</span><br><span class="line">&gt; cat hello.txt | grep -n yes</span><br></pre></td></tr></tbody></table></figure><p></p><h4 id="4-文件压缩与解压缩命令"><a href="#4-文件压缩与解压缩命令" class="headerlink" title="4.文件压缩与解压缩命令"></a><strong>4.文件压缩与解压缩命令</strong></h4><ul><li><strong>gzip</strong>压缩与<strong>gunzip</strong>解压缩指令</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">gzip 目标文件   <span class="comment"># 将指定文件压缩为*.gz文件</span></span><br><span class="line">gunzip *.gz文件   <span class="comment"># 将*.gz文件解压缩</span></span><br></pre></td></tr></tbody></table></figure><br><strong>-举例:</strong><br><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 将/home下的hello.txt文件压缩</span><br><span class="line">&gt; gzip /home hello.txt</span><br><span class="line">&gt; - 将/home下的hello.txt.gz文件解压缩</span><br><span class="line">&gt; gunzip /home hello.txt.gz</span><br></pre></td></tr></tbody></table></figure><br><strong>-特别说明</strong>：用gzip指令压缩文件后，源文件会被删除。<p></p><ul><li><strong>zip</strong>压缩与<strong>unzip</strong>解压缩:项目打包发布时非常有用</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">zip [选项] *.zip 目标文件/目录  <span class="comment"># 将指定文件/目录压缩为.zip文件</span></span><br><span class="line">unzip [选项] *.zip文件   <span class="comment"># 将*.zip文件解压缩</span></span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-r:递归压缩，即压缩目录 # 针对zip指令</li><li>-d:指定解压后文件所在位置 # 针对unzip指令<br><strong>-举例:</strong><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 将/home下的所有文件压缩为home.zip文件</span><br><span class="line">&gt; zip -r home.zip /home/</span><br><span class="line">&gt; - 将home.zip文件解压缩到/opt/tmp目录下</span><br><span class="line">&gt; unzip -d /opt/tmp /home/home.zip</span><br></pre></td></tr></tbody></table></figure></li></ul></blockquote><ul><li><strong>tar</strong>:压缩与解压缩</li></ul><p><strong>-语法:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar [选项] *.tar.gz 目标文件/目录 [-C](可选) <span class="comment"># 将文件/目录压缩或者将.tar.gz文件解压</span></span><br></pre></td></tr></tbody></table></figure><br><strong>-选项与参数:</strong><p></p><blockquote><ul><li>-c:产生.tar打包文件</li><li>-v:显示详细信息</li><li>-f:指定压缩后的文件名</li><li>-z:打包同时压缩</li><li>-x:解包.tar文件</li></ul><p><strong>-特别说明</strong>:在解压缩文件时，若要指定解压路径，将使用-C参数，用来指定位置。</p></blockquote><p><strong>-举例:</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&gt; - 压缩多个文件，将/home/zyhcs/Desktop/test.txt和hello.txt压缩成a.tar.gz文件</span><br><span class="line">&gt; <span class="built_in">cd</span> /home/zyhcs/Desktop</span><br><span class="line">&gt; tar -zcvf a.tar.gz hello.txt test.txt</span><br><span class="line">&gt; - 将/home的文件夹压缩成myhome.tar.gz文件</span><br><span class="line">&gt; tar -zcvf myhome.tar.gz /home/</span><br><span class="line">&gt; - 将a.tar.gz文件解压到当前目录</span><br><span class="line">&gt; tar -zxvf a.tar.gz</span><br><span class="line">&gt; - 将a.tar.gz文件夹压到/home下</span><br><span class="line">&gt; tar -zxvf a.tar.gz -C /home</span><br></pre></td></tr></tbody></table></figure><br><strong>-注意:</strong>解压文件指定位置时，该目录必须是存在的。<p></p><h4 id="5-其他常用命令"><a href="#5-其他常用命令" class="headerlink" title="5.其他常用命令:"></a><strong>5.其他常用命令:</strong></h4><p><strong>时间日期</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">date <span class="comment"># 查看系统时间</span></span><br><span class="line">date <span class="string">"+%Y-%m-%d %H:%M:%S"</span> <span class="comment"># 以自定格式查看日期</span></span><br><span class="line">date -s <span class="string">"2020-08-08 16:13:44"</span> <span class="comment"># 设置指定日期时间</span></span><br><span class="line">cal <span class="comment"># 查看当月日历</span></span><br><span class="line">cal 年份 <span class="comment"># 查看指定年份的日历</span></span><br></pre></td></tr></tbody></table></figure><p></p><p><strong>关机&amp;重启命令</strong><br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">shutdown -h now <span class="comment"># 立刻关机</span></span><br><span class="line">shutdown -h 1 <span class="comment"># 1分钟后关机</span></span><br><span class="line">shutdown -r now <span class="comment"># 立刻重启</span></span><br><span class="line">halt <span class="comment"># 作用同shutdown</span></span><br><span class="line">reboot <span class="comment"># 立刻重启</span></span><br><span class="line">sync <span class="comment"># 将内存中的数据同步到磁盘中</span></span><br></pre></td></tr></tbody></table></figure><p></p><p><strong>用户与管理员切换</strong></p><ul><li>普通用户-&gt;管理员root<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">su -</span><br><span class="line"><span class="comment">## 接着输入root用户密码</span></span><br></pre></td></tr></tbody></table></figure></li><li>管理员root-&gt;普通用户<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">su - 用户名</span><br></pre></td></tr></tbody></table></figure></li></ul><p><strong>Vi&amp;Vim编辑命令</strong></p><blockquote><p>Vi编辑有3中模式：</p><ol><li>使用vi或者vim命令打开文件时为正常模式；可以通过方向键控制光标移动，不可编辑</li><li>在键盘上输入i、I、o、O、s、S时进入插入(insert)模式：此时可以对文件内容进行编辑</li><li>在插入模式下，键入Esc，进入命令行模式：此时可以输入相应命令，完成相应的操作例如：退出Vim、显示行号等。</li></ol></blockquote><p>Vim中的快捷键：<br></p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">在命令行模式下：</span><br><span class="line"><span class="comment"># 查找指定单词 /(查找内容)  输入n，查找下一个</span></span><br><span class="line">dd <span class="comment"># 删除光标所在行  数字+dd # 删除光标所在行下指定数字行</span></span><br><span class="line">:w <span class="comment"># 保存内容 :wq # 保存并退出 :q # 退出 :q! #强制退出</span></span><br><span class="line">u <span class="comment"># 撤销上一步的操作  :set no # 显示行号</span></span><br></pre></td></tr></tbody></table></figure><p></p></article><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/Linux/">Linux</a><a class="post-meta__tags" href="/blog/tags/Command/">Command</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/zyhcs/image/raw/master/20201014202220.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload='this.media="all"'><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://gitee.com/zyhcs/image/raw/master/wechat.png" target="_blank"><img class="post-qr-code-img" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/wechat.png" alt="微信"></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="https://gitee.com/zyhcs/image/raw/master/alipay.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/alipay.jpg" alt="支付宝"></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/posts/f13a0ff4.html"><img class="prev-cover" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/601055c11d08.jpg" onerror='onerror=null,src="/blog/img/404.jpg"' alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">利用云主机搭建自己的MYSQL云服务器</div></div></a></div><div class="next-post pull-right"><a href="/blog/posts/764ee32a.html"><img class="next-cover" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/20201014203851.jpg" onerror='onerror=null,src="/blog/img/404.jpg"' alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">python更改pip镜像源</div></div></a></div></nav><hr><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i> <span>评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="https://gitee.com/zyhcs/image/raw/master/avatar.jpg" onerror='this.onerror=null,this.src="/blog/img/friend_404.gif"' alt="avatar"><div class="author-info__name">ZyhCs</div><div class="author-info__description">梦想总要有的，万一实现了呢.</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">9</div></a></div><div class="card-info-data-item is-center"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div><div class="card-info-data-item is-center"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/zyhcs"><i class="fab fa-heart"></i><span>关 注 我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/zyhcs" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:zyh.cjs@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">点关注 , 不迷路!</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E5%90%88%E9%9B%86-1"><span class="toc-text">Linux常用命令合集(1)</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%A4%84%E7%90%86%E7%9B%AE%E5%BD%95%E7%9A%84%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%EF%BC%9A"><span class="toc-text">1.处理目录的常用命令：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%86%85%E5%AE%B9%E6%9F%A5%E7%9C%8B%E7%9A%84%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="toc-text">2.内容查看的常用命令:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E6%90%9C%E7%B4%A2%E6%9F%A5%E6%89%BE%E7%B1%BB%E5%91%BD%E4%BB%A4%EF%BC%9A"><span class="toc-text">3.搜索查找类命令：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-%E6%96%87%E4%BB%B6%E5%8E%8B%E7%BC%A9%E4%B8%8E%E8%A7%A3%E5%8E%8B%E7%BC%A9%E5%91%BD%E4%BB%A4"><span class="toc-text">4.文件压缩与解压缩命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-%E5%85%B6%E4%BB%96%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="toc-text">5.其他常用命令:</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/b931fe9e.html" title="记录ABAP开发的日常——SAP_PO同步接口开发案例"><img data-lazy-src="https://gitee.com/zyhcs/image/raw/master/20210304160604.jpg" onerror='this.onerror=null,this.src="/blog/img/404.jpg"' alt="记录ABAP开发的日常——SAP_PO同步接口开发案例"></a><div class="content"><a class="title" href="/blog/posts/b931fe9e.html" title="记录ABAP开发的日常——SAP_PO同步接口开发案例">记录ABAP开发的日常——SAP_PO同步接口开发案例</a><time datetime="2022-01-20T13:35:00.000Z" title="发表于 2022-01-20 21:35:00">2022-01-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/8beb8acd.html" title="记录ABAP开发的日常——标准程序模板"><img data-lazy-src="https://gitee.com/zyhcs/image/raw/master/20210304160604.jpg" onerror='this.onerror=null,this.src="/blog/img/404.jpg"' alt="记录ABAP开发的日常——标准程序模板"></a><div class="content"><a class="title" href="/blog/posts/8beb8acd.html" title="记录ABAP开发的日常——标准程序模板">记录ABAP开发的日常——标准程序模板</a><time datetime="2021-03-02T22:50:00.000Z" title="发表于 2021-03-03 06:50:00">2021-03-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/efbf26c8.html" title="记录ABAP开发的日常——功能函数"><img data-lazy-src="https://gitee.com/zyhcs/image/raw/master/20210304160604.jpg" onerror='this.onerror=null,this.src="/blog/img/404.jpg"' alt="记录ABAP开发的日常——功能函数"></a><div class="content"><a class="title" href="/blog/posts/efbf26c8.html" title="记录ABAP开发的日常——功能函数">记录ABAP开发的日常——功能函数</a><time datetime="2021-03-02T05:50:00.000Z" title="发表于 2021-03-02 13:50:00">2021-03-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/8d3bbb71.html" title="记录ABAP开发的日常——常用日期函数"><img data-lazy-src="https://gitee.com/zyhcs/image/raw/master/20210228142122.jpg" onerror='this.onerror=null,this.src="/blog/img/404.jpg"' alt="记录ABAP开发的日常——常用日期函数"></a><div class="content"><a class="title" href="/blog/posts/8d3bbb71.html" title="记录ABAP开发的日常——常用日期函数">记录ABAP开发的日常——常用日期函数</a><time datetime="2021-03-01T00:32:11.000Z" title="发表于 2021-03-01 08:32:11">2021-03-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/posts/93481df2.html" title="butterfly主题标签插件——Tag Plugin Plus"><img data-lazy-src="https://gitee.com/zyhcs/image/raw/master/dongman-3.jpg" onerror='this.onerror=null,this.src="/blog/img/404.jpg"' alt="butterfly主题标签插件——Tag Plugin Plus"></a><div class="content"><a class="title" href="/blog/posts/93481df2.html" title="butterfly主题标签插件——Tag Plugin Plus">butterfly主题标签插件——Tag Plugin Plus</a><time datetime="2021-02-28T16:57:11.000Z" title="发表于 2021-03-01 00:57:11">2021-03-01</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By ZyhCs</div><div class="footer_custom_text">Hi, welcome to my <a href="https://zyhcs.gitee.io/blog">blog</a>!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"></div></div></div><hr><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="/blog/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn(){"object"==typeof pangu?pangu.autoSpacingPage():getScript("https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js").then(()=>{pangu.autoSpacingPage()})}function panguInit(){GLOBAL_CONFIG_SITE.isPost&&panguFn()}document.addEventListener("DOMContentLoaded",panguInit)</script><script src="/blog/js/search/local-search.js"></script><script>var preloader={endLoading:()=>{document.body.style.overflow="auto",document.getElementById("loading-box").classList.add("loaded")},initLoading:()=>{document.body.style.overflow="",document.getElementById("loading-box").classList.remove("loaded")}};window.addEventListener("load",preloader.endLoading())</script><div class="js-pjax"><script>if(window.MathJax)MathJax.startup.document.state(0),MathJax.texReset(),MathJax.typeset();else{window.MathJax={loader:{source:{"[tex]/amsCd":"[tex]/amscd"}},tex:{inlineMath:[["$","$"],["\\(","\\)"]],tags:"ams"},options:{renderActions:{findScript:[10,t=>{for(const e of document.querySelectorAll('script[type^="math/tex"]')){const a=!!e.type.match(/; *mode=display/),n=new t.options.MathItem(e.textContent,t.inputJax[0],a),s=document.createTextNode("");e.parentNode.replaceChild(s,e),n.start={node:s,delim:"",n:0},n.end={node:s,delim:"",n:0},t.math.push(n)}},""],addClass:[200,()=>{document.querySelectorAll("mjx-container:not([display='true']").forEach(t=>{const e=t.parentNode;e.classList.contains("has-jax")||e.classList.add("mathjax-overflow")})},"",!1]}}};const t=document.createElement("script");t.src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js",t.id="MathJax-script",t.async=!0,document.head.appendChild(t)}</script><script>document.getElementsByClassName("mermaid").length&&(window.mermaidJsLoad?mermaid.init():getScript("https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js").then(()=>{window.mermaidJsLoad=!0,mermaid.initialize({theme:"default"}),mermaid.init()}))</script><script>function loadValine(){function e(){let e={el:"#vcomment",appId:"f05VNWs1jpaDIrceIX470ywy-MdYXbMMI",appKey:"0zL7bvdCHiNd6nnBHUs4tTnk",placeholder:"快来发表你的意见吧！&lt;－biubiu－⊂(`ω´∩)",avatar:"monsterid",meta:"nick,mail,link".split(","),pageSize:"10",lang:"zh-CN",recordIP:!0,serverURLs:"",emojiCDN:"",emojiMaps:"",enableQQ:!0,path:window.location.pathname,master:"d4e7????4d361ad7????44a14e9e2a94".split(","),friends:"5c?????bfe6rfc72a????e268ad3819c,7c?????bfe65fc02a????e2????3919c".split(","),tagMeta:"博主,小伙伴,访客".split(",")};e.requiredFields="nick,mail".split(",");new Valine(e)}"function"==typeof Valine?e():getScript("https://cdn.jsdelivr.net/gh/HCLonely/Valine@latest/dist/Valine.min.js").then(e)}{function loadOtherComment(){loadValine()}btf.loadComment(document.getElementById("vcomment"),loadValine)}</script></div><script src="https://cdn.jsdelivr.net/npm/blueimp-md5@2.17.0/js/md5.min.js"></script><script>window.addEventListener("load",()=>{const e=(e,t)=>{if(e)return e;return"https://gravatar.loli.net/avatar/"+(md5(t.toLowerCase())+"?d=monsterid")},t=e=>{let t="";if(e.length)for(let a=0;a<e.length;a++){t+="<div class='aside-list-item'>";{const n="data-lazy-src";t+=`<a href='${e[a].url}' class='thumbnail'><img ${n}='${e[a].avatar}' alt='${e[a].nick}'></a>`}t+=`<div class='content'>\n        <a class='comment' href='${e[a].url}'>${e[a].content}</a>\n        <div class='name'><span>${e[a].nick} / </span><time datetime="${e[a].date}">${btf.diffDate(e[a].date,!0)}</time></div>\n        </div></div>`}else t+="没有评论";let a=document.querySelector("#card-newest-comments .aside-list");a.innerHTML=t,window.lazyLoadInstance&&window.lazyLoadInstance.update(),window.pjax&&window.pjax.refresh(a)},a=()=>{if(document.querySelector("#card-newest-comments .aside-list")){const a=saveToLocal.get("valine-newest-comments");a?t(JSON.parse(a)):fetch("https://f05VNWs1.api.lncldglobal.com/1.1/classes/Comment?limit=6&order=-createdAt",{method:"GET",headers:{"X-LC-Id":"f05VNWs1jpaDIrceIX470ywy-MdYXbMMI","X-LC-Key":"0zL7bvdCHiNd6nnBHUs4tTnk","Content-Type":"application/json"}}).then(e=>e.json()).then(a=>{const n=a.results.map((function(t){return{avatar:e(t.QQAvatar,t.mail),content:(a=t.comment,""===a||(a=(a=(a=(a=a.replace(/<img.*?src="(.*?)"?[^\>]+>/gi,"[图片]")).replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,"[链接]")).replace(/<pre><code>.*?<\/pre>/gi,"[代码]")).replace(/<[^>]+>/g,"")).length>150&&(a=a.substring(0,150)+"..."),a),nick:t.nick,url:t.url+"#"+t.objectId,date:t.updatedAt};var a}));saveToLocal.set("valine-newest-comments",JSON.stringify(n),10/1440),t(n)}).catch(e=>{document.querySelector("#card-newest-comments .aside-list").innerHTML="无法获取评论，请确认相关配置是否正确"})}};a(),document.addEventListener("pjax:complete",a)})</script><div class="app-refresh" id="app-refresh"><div class="app-refresh-wrap"><label>✨ 網站已更新最新版本 👉</label> <a href="javascript:void(0)" onclick="location.reload()">點擊刷新</a></div></div><script>function showNotification(){if(GLOBAL_CONFIG.Snackbar){var t="light"===document.documentElement.getAttribute("data-theme")?GLOBAL_CONFIG.Snackbar.bgLight:GLOBAL_CONFIG.Snackbar.bgDark,e=GLOBAL_CONFIG.Snackbar.position;Snackbar.show({text:"已更新最新版本",backgroundColor:t,duration:5e5,pos:e,actionText:"點擊刷新",actionTextColor:"#fff",onActionClick:function(t){location.reload()}})}else{var o=`top: 0; background: ${"light"===document.documentElement.getAttribute("data-theme")?"#49b1f5":"#1f1f1f"};`;document.getElementById("app-refresh").style.cssText=o}}"serviceWorker"in navigator&&(navigator.serviceWorker.controller&&navigator.serviceWorker.addEventListener("controllerchange",(function(){showNotification()})),window.addEventListener("load",(function(){navigator.serviceWorker.register("/sw-template.js")})))</script><script async src="//at.alicdn.com/t/font_2264842_3izu8i5eoc2.js"></script><script defer src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@latest/source/js/issues.min.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zindex="-1" mobile="false" data-click="true"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful=!0,POWERMODE.shake=!0,POWERMODE.mobile=!1,document.body.addEventListener("input",POWERMODE)</script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors=["title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"];var pjax=new Pjax({elements:'a:not([target="_blank"]):not([href="/music/"]):not([href="/no-pjax/"])',selectors:pjaxSelectors,cacheBust:!1,analytics:!1,scrollRestoration:!1});document.addEventListener("pjax:complete",(function(){window.refreshFn(),document.querySelectorAll("script[data-pjax]").forEach(e=>{const t=document.createElement("script"),o=e.text||e.textContent||e.innerHTML||"";Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.appendChild(document.createTextNode(o)),e.parentNode.replaceChild(t,e)}),GLOBAL_CONFIG.islazyload&&window.lazyLoadInstance.update(),"function"==typeof chatBtnFn&&chatBtnFn(),"function"==typeof panguInit&&panguInit(),"function"==typeof gtag&&gtag("config","",{page_path:window.location.pathname}),"function"==typeof loadMeting&&document.getElementsByClassName("aplayer").length&&loadMeting(),"object"==typeof Prism&&Prism.highlightAll(),"object"==typeof preloader&&preloader.endLoading()})),document.addEventListener("pjax:send",(function(){if("object"==typeof preloader&&preloader.initLoading(),window.aplayers)for(let e=0;e<window.aplayers.length;e++)window.aplayers[e].options.fixed||window.aplayers[e].destroy();"object"==typeof typed&&typed.destroy();const e=document.body.classList;e.contains("read-mode")&&e.remove("read-mode")})),document.addEventListener("pjax:error",e=>{404===e.request.status&&pjax.loadUrl("/404.html")})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>